#pragma once

#include "tbb/task_scheduler_init.h"
#include "tbb/parallel_for.h"
#include "tbb/blocked_range.h"

using namespace tbb;

double* sum_TBB(double *mtx1, double *mtx2, int weight, int height);

class MatrixSummator
{
	const double* mtx1, *mtx2;
	double *const res;
	int w, h;

public:
	MatrixSummator( double* tmtx1, double* tmtx2, double* tres, int tw, int th) : mtx1( tmtx1 ), 
		mtx2( tmtx2 ), res( tres ), w( tw ), h( th ) {}

	void operator () ( const blocked_range<int>& r ) const
	{
		int start = r.begin();
		int finish = r.end();

		for( int i = start; i < finish; i++)
			res[i] = mtx1[i] + mtx2[i];
	}
};